package Host;

use strict;
use warnings;

use Data::Dumper;

use NetAddr::IP;

use base qw (NetworkDB);

__PACKAGE__->set_up_table('addresses');
__PACKAGE__->has_a(plugid => 'Plug');

sub IP2MAC {
	my $self = shift;
	my $IP = shift;
#	warn $IP;
	$IP = NetAddr::IP->new($IP);
	my $MAC = $self->search( ip => $IP->addr )->next->mac;
	return $MAC || 0;
}

sub MAC2IP {
	my $self = shift;
	my $MAC = shift;
# changed 6.3.2006 by ostry
#	my $obj = $self->search( mac => $MAC )->next;
	my @obj = $self->search( mac => $MAC );

#	if (defined $obj) {
#	if ($#obj > -1) {

		return @obj;

#	} else {
#		return 0;
#	}
}

1;
